// SSITemplateMain.cpp
// author: Johannes Wagner <johannes.wagner@informatik.uni-augsburg.de>
// created: xxxx/xx/xx
// Copyright (C) University of Augsburg

#include "ssi.h"
#include "SimpleLpFilter.h"
using namespace ssi_sensor;
using namespace ssi_frame;
using namespace ssi_graphic;
using namespace ssi_ioput;
using namespace ssi_signal;

#ifdef USE_SSI_LEAK_DETECTOR
	#include "SSI_LeakWatcher.h"
	#define new DEBUG_NEW
	#undef THIS_FILE
	static char THIS_FILE[] = __FILE__;
#endif

#ifdef USE_VLD_LEAK_DETECTOR
	#include "vld.h"
#endif

int main (int argc, char **argv) {


	char info[1024];
	ssi_sprint (info, "\n%s\n\nbuild version: %s\n\n", SSI_COPYRIGHT, SSI_VERSION);
	TheFramework::Instance ()->SetAutoThread (true);
	ssi_time_t sample_rate = 20.0;
	ssi_time_t packet_size = 0.5;

	Provider mouse_p;
	MouseSensor mouse (&mouse_p, 0, sample_rate, packet_size);

	SimpleLpFilter swap;
	Transformer swap_t (mouse_p.getBufferId (), &swap, 0.1);

	int plot_id = ThePainter::Instance ()->AddCanvas ("Mouse");
	Plotter<ssi_real_t> plot_raw (plot_id, PAINT_TYPE_PATH);
	Consumer plot_raw_c (mouse_p.getBufferId (), &plot_raw, 2.0);

	plot_id = ThePainter::Instance ()->AddCanvas ("Mouse SimpleLpFilter(Filter)");
	Plotter<ssi_real_t> plot_trans (plot_id, PAINT_TYPE_PATH);
	Consumer plot_trans_c (swap_t.getBufferId (), &plot_trans, 2.0);

	ThePainter::Instance ()->Arrange (2, 1, 50, 50, 800, 400);
	mouse.start ();
	TheFramework::Instance ()->Start ();

	ssi_print ("Press enter to stop!\n");
	getchar ();
	
	TheFramework::Instance ()->Stop ();
	mouse.stop ();
	TheFramework::Instance ()->Shutdown ();
	ThePainter::Instance ()->Shutdown ();


	return 0;
}
